package com.easy.venue.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easy.common.bean.OrderBean;
import com.easy.common.bean.SeatBean;
import com.easy.common.bean.UserBean;
import com.easy.common.service.ISeatService;
import com.easy.common.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/seat")
public class SeatController {
    @Autowired
    ISeatService seatService;

    @GetMapping("/getSeatById/{id}")
    public Result getSeatById(@PathVariable("id") Integer id) {
        Object obj=seatService.getSeatById(id);
        return Result.success(obj);
    }
    @PostMapping("/add")
    public Result addSeat(@RequestBody SeatBean seat) {
       int result=seatService.addSeat(seat);
       if(result>0){
           return Result.success(200,"添加座位信息成功", seat);
       }
       return Result.fail(400,"添加座位信息失败");
    }

    @PutMapping("/edit")
    public Result updateSeat(@RequestBody SeatBean seatBean) {
        Object obj=seatService.updateSeat(seatBean);
        return Result.success(obj);
    }
    @DeleteMapping("/deleteSeat/{id}")
    public Result deleteSeat(@PathVariable("id") Integer id) {
        Object obj=seatService.deleteSeat(id);
        return Result.success(obj);
    }
    @GetMapping("/all")
    public Result getAll(SeatBean seatBean) {
        Object obj=seatService.getAll(seatBean);
        return Result.success(obj);
    }
    @GetMapping("/page")
    public Result getPage(SeatBean seat,Page<SeatBean> page) {
        IPage<SeatBean> getConcertTitle = seatService.getConcertTitle(page);
        return Result.success(getConcertTitle);
//        seatService.getPage(seat, page);
//        return Result.success(page);
    }

    @GetMapping("/getSeatsByConcertId/{concertId}")
    public Result getSeatsByConcertId(@PathVariable Integer concertId) {
        List<SeatBean> seats = seatService.lambdaQuery()
                .eq(SeatBean::getConcertid, concertId)
                .list();
        return Result.success(seats);
    }

    @GetMapping("/getConcertTitle")
    public Result getConcertTitle(Page<SeatBean> page) {
        IPage<SeatBean> getConcertTitle = seatService.getConcertTitle(page);
        return Result.success(getConcertTitle);
    }

}


































